(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.job.viewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'jobService' ];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, jobService) {
		var ctrl = this, jobInfo = $scope.$stateParams.params;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.job = {};
		ctrl.job.jobDepencyList = ctrl.job.jobDepencyList || [];
		ctrl.job.jobParmetes = ctrl.job.jobParmetes || [];
		ctrl.init = function() {
			var params = {
				jobId : jobInfo.jobId
			};
			ctrl.innerGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.jobDepency.tableConfigs.table);
			ctrl.innerGridOptions.data = 'vm.job.jobDepencyList';
			ctrl.innerGridOptions.enableRowHeaderSelection = false;
			ctrl.jobParmetesOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.jobParameters.tableConfigs.table);
			ctrl.jobParmetesOptions.data = 'vm.job.jobParmetes';
			ctrl.jobParmetesOptions.enableRowHeaderSelection = false;
			jobService.initDataOptions(ctrl);
			return authService.view(params).then(function(response) {
				ctrl.job = response.data || jobInfo;
			}, angular.noop);
		};
	}
})(angular);